package com.spring;

import com.spring.app.AppConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Main {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class);


        String[] beans = applicationContext.getBeanDefinitionNames();

        System.out.println(beans.length);

        for (String bean : beans) {
            Class<?> beanType = applicationContext.getType(bean);
            System.out.println("BeanName:" + bean);
            System.out.println("Bean的类型：" + beanType);
            System.out.println("Bean所在的包：" + beanType.getPackage());
            System.out.println("Bean：" + applicationContext.getBean(bean));
        }
    }
}
